/*
 * @Author: Turump 
 * @Date: 2021-04-26 10:01:10 
 * @Last Modified by: Turump
 * @Last Modified time: 2021-04-26 10:16:05
 */

import { TweenType } from "../../misc/TweenType";
import ActionBaseTask from "./ActionBaseTask";

const { ccclass, property, menu } = cc._decorator;

@ccclass
@menu("动作任务/ScaleBy")
export default class ScaleByTask extends ActionBaseTask {

    @property({ displayName: "缩放参数" })
    scaleByVec: cc.Vec2 = cc.v2(0, 0);

    @property()
    reverse = false;

    @property({ displayName: "循环次数", tooltip: "无限循环就把数字设大一点", visible() { return this.reverse } })
    repeatTime = 1;

    getAction() {
        let tween: cc.Tween = null;
        if (this.reverse == false) {
            tween = cc.tween(this.node)
                .delay(this.delayTime)
                .then(this.getPlayAudioTween())
                .by(this.actionDuration, { scaleX: this.scaleByVec.x, scaleY: this.scaleByVec.y })
        } else {
            tween = cc.tween(this.node)
                .delay(this.delayTime).
                repeat(this.repeatTime,
                    cc.tween(this.node)
                        .then(this.getPlayAudioTween())
                        .by(this.actionDuration, { scaleX: this.scaleByVec.x, scaleY: this.scaleByVec.y })
                        .by(this.actionDuration, { scaleX: -this.scaleByVec.x, scaleY: -this.scaleByVec.y })
                )
        }

        return tween;
    }
}
